package com.zxk.service.impl;

import com.sun.jna.platform.win32.WinDef;
import com.zxk.constant.JNAConstants;
import com.zxk.constant.PicConstants;
import com.zxk.service.AbstractMyTask;
import com.zxk.util.FuzzyPicUtil;
import com.zxk.util.KeyUtil;

/**
 * 领取双倍点数任务
 *
 * @author: 舟小亢
 * @date: 2024-06-27 23:33
 */
public class ReceivePointTaskImpl extends AbstractMyTask {

    public ReceivePointTaskImpl(WinDef.HWND hwnd_0, WinDef.HWND hwnd_1, WinDef.HWND hwnd_2) {
        super(hwnd_0, hwnd_1, hwnd_2);
    }

    @Override
    public String getTaskName() throws Exception {
        return "领取双倍";
    }

    @Override
    public boolean execute() throws Exception {
        if (!FuzzyPicUtil.findAndClickRandom(hwnd_0, hwnd_1, PicConstants.公共_挂机, 3)) {
            return false;
        }
        for (int j = 0; j < 5; j++) {
            FuzzyPicUtil.findAndClickRandom(hwnd_0, hwnd_1, PicConstants.抓鬼任务_领取点数, 1);
        }
        // 如果点数不够，点击取消
        FuzzyPicUtil.findAndClickRandom(hwnd_0, hwnd_1, PicConstants.抓鬼任务_领取点数取消, 3);
        // 退出界面
        KeyUtil.kClick(hwnd_1, JNAConstants.VK_ESCAPE);
        if (!FuzzyPicUtil.findPic(hwnd_0, PicConstants.公共_活动, 3).isFinded()) {
            return false;
        }
        return true;
    }
}
